package com.ovolucky.mapmytrip.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import com.ovolucky.mapmytrip.app.storage.TripStore;

import java.util.List;

public class MainActivity extends Activity {
  private TripStore tripStore;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    tripStore = new TripStore(this);
    List<TripStore.TripMetadata> trips = tripStore.listAllTrips();
    if (trips.isEmpty()) {
      setContentView(R.layout.activity_main);
      Button createButton = (Button) findViewById(R.id.createTripButton);
      createButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
          startActivity(new Intent(getBaseContext(), CreateTripActivity.class));
        }
      });
    } else {
      startActivity(new Intent(this, MapActivity.class));
    }
  }
}
